package com.zff.rental.controller.apartment;


import com.zff.rental.common.Result;
import com.zff.rental.service.apartment.DeviceDictServer;
import com.zff.rental.vo.apartment.deviceDict.AddDeviceDictParams;
import com.zff.rental.vo.apartment.deviceDict.DeviceDictVo;
import com.zff.rental.vo.apartment.deviceDict.ModifyDeviceDictParams;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 房屋配套管理
 *
 * @author HCY
 */
@RestController
@RequestMapping("/deviceManage")
public class DeviceDictManageController {
    @Resource
    private DeviceDictServer deviceDictServer;

    /**
     * 添加房屋配套字典
     */
    @PostMapping("/add")
    public Result<DeviceDictVo> add(@Validated @RequestBody AddDeviceDictParams params) {
        DeviceDictVo result = deviceDictServer.add(params);
        return Result.success(result);
    }

    /**
     * 修改房屋配套字典
     */
    @PostMapping("/modify")
    public Result<DeviceDictVo> modify(@Validated @RequestBody ModifyDeviceDictParams params) {
        DeviceDictVo result = deviceDictServer.modify(params);
        return Result.success(result);
    }

    /**
     * 批量修改房屋配套字典
     */
    @PostMapping("/batchModify")
    public Result<List<DeviceDictVo>> batchModify(@Validated @RequestBody List<ModifyDeviceDictParams> params) {
        List<DeviceDictVo> result = deviceDictServer.batchModify(params);
        return Result.success(result);
    }

    /**
     * 删除房屋配套字典
     */
    @GetMapping("/remove")
    public Result<Boolean> remove(@RequestParam("id") Long id) {
        Boolean result = deviceDictServer.remove(id);
        return Result.success(result);
    }

    /**
     * 房屋配套字典详情
     */
    @GetMapping("/details")
    public Result<DeviceDictVo> details(@RequestParam("id") Long id) {
        DeviceDictVo result = deviceDictServer.details(id);
        return Result.success(result);
    }

    /**
     * 房屋配套字典列表
     */
    @GetMapping("/all")
    public Result<List<DeviceDictVo>> all() {
        List<DeviceDictVo> result = deviceDictServer.all();
        return Result.success(result);
    }
}